﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;



namespace Dreaming_of_Space_2
{
    
    
    public class Tower
    {
        public int damage=1;
        public Point Pos;
        public int fire_distance=60;
        public string FireType="laser";
        public bool select=false;
        public bool is_fire = false;
        public bool SetTower(int x_MouseDown_1, int y_MouseDown_1, Graphics myGraphics)
        {
            
            Pen myPen = new Pen(Color.Black, 1);
           // Graphics myGraphics = CreateGraphics();
            
            //Создаем и рисуем огневую точку:
            Rectangle myRectangle = new Rectangle(
            new Point(x_MouseDown_1-5, y_MouseDown_1-5),
            new Size(10, 10));
            myGraphics.DrawRectangle(new Pen(Color.Transparent),
                                                        myRectangle);

              
            //установка радиуса поражения
            Pen  myPen1 = new Pen(Color.Red, 1);
            myPen1.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            myGraphics.DrawEllipse(myPen1, x_MouseDown_1 - fire_distance, y_MouseDown_1 - fire_distance,
               fire_distance * 2, fire_distance*2);

            LinearGradientBrush myBrush;
            myBrush = new LinearGradientBrush(myRectangle,
                Color.White, Color.Black,
                LinearGradientMode.Horizontal);

            myGraphics.FillEllipse(myBrush, myRectangle);

            // Create string to draw.
            String drawString = damage.ToString();
            // Create font and brush.
            Font drawFont = new Font("Arial", 8);
            SolidBrush drawBrush = new SolidBrush(Color.Green);
            // Create point for upper-left corner of drawing.
            float x = Pos.X-15;
            float y = Pos.Y-15;
            myGraphics.DrawString(drawString, drawFont, drawBrush, x, y);

            if (select == true) Select(myGraphics);
            return true;
        }
        public bool Select(Graphics myGraphics)
        {
            Pen myPen = new Pen(Color.ForestGreen, 1);
            Point[] SelectPoints = new Point[3];
            SelectPoints[0].X=Pos.X-15;
            SelectPoints[0].Y=Pos.Y-10;
            SelectPoints[1].X=Pos.X-15;
            SelectPoints[1].Y=Pos.Y-15;
            SelectPoints[2].X=Pos.X-10;
            SelectPoints[2].Y=Pos.Y-15;
            myGraphics.DrawLines(myPen, SelectPoints);

            SelectPoints[0].X = Pos.X + 10;
            SelectPoints[0].Y = Pos.Y - 15;
            SelectPoints[1].X = Pos.X + 15;
            SelectPoints[1].Y = Pos.Y - 15;
            SelectPoints[2].X = Pos.X + 15;
            SelectPoints[2].Y = Pos.Y - 10;
            myGraphics.DrawLines(myPen, SelectPoints);

            SelectPoints[0].X = Pos.X + 15;
            SelectPoints[0].Y = Pos.Y + 10;
            SelectPoints[1].X = Pos.X + 15;
            SelectPoints[1].Y = Pos.Y + 15;
            SelectPoints[2].X = Pos.X + 10;
            SelectPoints[2].Y = Pos.Y + 15;
            myGraphics.DrawLines(myPen, SelectPoints);

            SelectPoints[0].X = Pos.X - 10;
            SelectPoints[0].Y = Pos.Y + 15;
            SelectPoints[1].X = Pos.X - 15;
            SelectPoints[1].Y = Pos.Y + 15;
            SelectPoints[2].X = Pos.X - 15;
            SelectPoints[2].Y = Pos.Y + 10;
            myGraphics.DrawLines(myPen, SelectPoints);
            return true;

        }
        
        }
    }

